package com.eight.clienthome.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.eight.clienthome.dao.ArticleDao;
import com.eight.clienthome.service.ArticleService;
import com.eight.common.pojo.TbArticle;
import com.eight.common.pojo.TbLink;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import sun.plugin.javascript.navig.Link;

import java.util.List;

/**
 * @author 向文豪
 * @program: eight-education-parent
 * @description:
 * @date 2023/6/1 21:14
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleDao articleDao;
    @Override
    public List<TbArticle> findAll() {
        QueryWrapper<TbArticle> wrapper = new QueryWrapper<>();
        wrapper.eq("is_delete",0);
        List<TbArticle> tbArticles = articleDao.selectList(wrapper);
        return tbArticles;
    }

    @Override
    public TbArticle findById(String id) {
        QueryWrapper<TbArticle> wrapper = new QueryWrapper<>();
        if (StringUtils.hasText(id)){
            wrapper.eq("nav_id",id);
        }
        TbArticle article = articleDao.selectOne(wrapper);
        //TbArticle article = articleDao.selectById(id);
        return article;
    }
}
